﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class admin_edjobdetail : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        connection con = new connection();
        SqlConnection cn = con.connect();
        String id = Request.QueryString["id"] != null ? Request.QueryString["id"].ToString() : "";

        String lang = Request.QueryString["lang"] != null ? Request.QueryString["lang"].ToString() : "";
        String sql = "select * from [JobsDetails] where id = @id and lang = @lang";
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandText = sql;
        cmd.Parameters.AddWithValue("id", id);
        cmd.Parameters.AddWithValue("lang", lang);
        try
        {
            SqlDataReader rd = cmd.ExecuteReader();
            if (rd.HasRows)
            {
                rd.Read();
                ddlID.SelectedValue = rd.GetInt64(6).ToString();
                ddlLang.SelectedValue = rd.GetSqlString(1).ToString();
                hdfDetailID.Value = rd.GetInt64(0).ToString();
                menu.Text = rd.GetSqlString(2).ToString();
                title.Text = rd.GetSqlString(3).ToString();
                fckDes.Value = rd.GetSqlString(4).ToString();
                fckContent.Value = rd.GetSqlString(5).ToString();
            }
            rd.Close();
            cn.Close();
        }
        catch (Exception ex)
        {
            Response.Redirect("Default.aspx?page=qljobdetail");
        }

    }

    protected void addbt_Click(object sender, EventArgs e)
    {
        
        hdfContent.Value = fckContent.Value;
        hdfDes.Value = fckDes.Value;
        SqlDataSource2.Update();
        SqlDataSource2.DataBind();
        Response.Write("<script>alert('Update Thành Công')</script>");
        Response.Redirect("Default.aspx?page=qljobdetail");
    }
}